package com.icinfo.cloud.provider.punish.ucase.casemain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.ObjectUtils;

/**
 * 描述：案件状态枚举类
 *
 * @author shishengyao
 * @description
 * @date 2022/5/18
 */
@AllArgsConstructor
public enum CaseStatusEnum {
    /**
     * 案件状态枚举类
     */
    CASE_REGISTER("0", "待立案"),
    CASE_APPROVE("1", "立案审批"),
    HANDLING_CASE("2", "办案中"),
    END_CASE("3", "结案"),
    TEMP("4", "立案暂存"),
    SUSPEND("5", "暂停/中止"),
    TERMINATE("8", "终止"),
    POSTPONE("6", "案件延期"),
    REVOKE("7", "立案撤销"),
    PUNISH_REVOKE("9", "决定撤销"),
    PUNISH_NO_REGISTER("10", "不予立案"),
    HANDLING_CRIMINAL_TRANSFER("11", "涉刑移送处理中"),
    END_CRIMINAL_TRANSFER("12", "涉刑移送结案"),
    /**
     * 简易程序撤销
     */
    SIMPLE_CASE_REVOKE("13", "已撤销"),
    /**
     * 已移送
     */
    TRANSFERRING("14", "已移交");


    /**
     * 编码
     */
    @Getter
    private String code;
    /**
     * 描述
     */
    @Getter
    private String des;

    /**
     * 描述：根据code获取value
     *
     * @param code 编码
     * @return 描述内容
     * @author xiangyuyu
     * @date 2022-02-22 10:43
     */
    public static String getValueByCode(String code) {
        if (ObjectUtils.isEmpty(code)) {
            return null;
        }
        for (CaseStatusEnum e : CaseStatusEnum.values()) {
            if (code.equals(e.getCode())) {
                return e.getDes();
            }
        }
        return null;
    }

    /**
     * 描述：校验code是否是合法枚举
     *
     * @param code 枚举code
     * @return boolean 是否合法枚举（true-是/false-否）
     * @author xiangyuyu
     * @date 2022-02-22 10:42
     */
    public static boolean isLegalEnumCode(String code) {
        boolean flag = false;
        for (CaseStatusEnum e : CaseStatusEnum.values()) {
            if (e.getCode().equalsIgnoreCase(code)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
